package com.gitee.wsl.mathematics.number

import com.gitee.wsl.ext.number.clamp
import com.gitee.wsl.ext.number.isFuzzyEqual

interface DoubleCalcContainer: NumberCalcContainer<Double> {

    override val zero: Double
        get() = 0.0
    override val NaN: Double
        get() = Double.NaN
    override val POSITIVE_INFINITY: Double
        get() = Double.POSITIVE_INFINITY
    override val NEGATIVE_INFINITY: Double
        get() = Double.NEGATIVE_INFINITY
    override val MAX_VALUE: Double
        get() = Double.MAX_VALUE
    override val MIN_VALUE: Double
        get() = Double.MIN_VALUE

    override fun Double.divBy(a: Number): Double = a.toDouble() / this

    override fun Double.rem(a: Number): Double = this % a.toDouble()

    override fun Double.remBy(a: Number): Double = a.toDouble() % this

    override fun sin(a: Double): Double = kotlin.math.sin(a)

    override fun asin(a: Double): Double = kotlin.math.asin(a)

    override fun cos(a: Double): Double = kotlin.math.cos(a)

    override fun abs(a: Double): Double = kotlin.math.abs(a)

    override fun sign(a: Double): Double = kotlin.math.sign(a)

    override fun ceil(a: Double): Double = kotlin.math.ceil(a)

    override fun floor(a: Double): Double = kotlin.math.floor(a)

    override fun round(a: Double): Double = kotlin.math.round(a)

    override fun sqrt(a: Double): Double = kotlin.math.sqrt(a)

    override fun acos(a:Double): Double = kotlin.math.acos(a)

    override fun atan2(a: Double, b: Double): Double = kotlin.math.atan2(a,b)

    override fun tan(a: Double): Double = kotlin.math.tan(a)

    override fun isFuzzyZero(a: Double): Boolean = com.gitee.wsl.ext.number.isFuzzyEqual(a,0.0)

    override fun isFuzzyEqual(a: Double, b: Double): Boolean = com.gitee.wsl.ext.number.isFuzzyEqual(a,b)

    override fun min(a: Double, b: Double): Double = kotlin.math.min(a,b)

    override fun max(a: Double, b: Double): Double = kotlin.math.max(a,b)

    override fun Number.plus(x: Number): Double = toDouble() + x.toDouble()

    override fun Number.minus(x: Number): Double = toDouble() - x.toDouble()

    override fun Number.times(x: Number): Double = toDouble() * x.toDouble()

    override fun Number.div(x: Number): Double = toDouble() / x.toDouble()

    override fun Number.unaryMinus(): Double = -toDouble()

    override fun Number.unaryPlus(): Double = +toDouble()

    override fun clamp(r: Double, a: Double, b: Double) = r.clamp(a,b)

    override fun hypot(a: Double, b: Double): Double = kotlin.math.hypot(a,b)

    override fun Double.inRange(start: Double, end: Double): Boolean = this in start..end

    override fun Double.inRangeOpen(start: Double, end: Double): Boolean = this in start ..< end

    override fun mapValue(
        start1: Double,
        stop1: Double,
        start2: Double,
        stop2: Double,
        value: Double,
        withBounds: Boolean,
    ): Double = com.gitee.wsl.ext.number.map(start1, stop1, start2, stop2, value,withBounds)
}